import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { Language } from "../../../../../extend/language/Language";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { RewardCodeRenderer } from "./RewardCodeRenderer";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class RewardRenderer
    
    export  class RewardRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this._itemArr = [];
            return;
        }

        protected /* override */ configUI(): void
        {
            ObjCreate.createBg(5, 78, 230, 2, this, ImagesConst.SplitLine);
            var loc1=new GTextFormat(FontUtil.xingkaiName, 14, 6350622);
            this._rankTxt = ObjCreate.createGTextField("", 80, 3, 100, 30, this, loc1);
            ObjCreate.createGTextField(Language.getString(36290), 15, 40, 80, 20, this);
            LoaderHelp.addResCallBack(ResFileConst.InterFlowerRank, this.onResLoaded);
            return;
        }

        /* internal  */onResLoaded(): void
        {
            this._rankBmp = ObjCreate.createBitmap(ImagesConst.RewardRank, 10, 5, this);
            this._rankTxt.x = this._rankBmp.x + this._rankBmp.width + 10;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc3=null;
            var loc4=null;
            super.data = arg1;
            if (arg1 == null) 
            {
                return;
            }
            this.removeItem();
            var loc1=arg1.key;
            this._rankTxt.text = loc1;
            var loc2=arg1.reward as Array<any>;
            var loc5=60;
            var loc6=25;
            var loc7=0;
            while (loc7 < loc2.length) 
            {
                if (loc3 = loc2[loc7]) 
                {
                    (loc4 = new RewardCodeRenderer()).data = loc3;
                    loc4.x = loc5;
                    loc4.y = loc6;
                    loc5 = loc5 + 45;
                    addChild(loc4);
                    this._itemArr.push(loc4);
                }
                ++loc7;
            }
            return;
        }

        /* internal  */removeItem(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._itemArr.length) 
            {
                loc1 = this._itemArr[loc2];
                removeChild(loc1);
                ++loc2;
            }
            this._itemArr.splice(0);
            return;
        }

        /* internal */ /* var */_rankBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_rankTxt: GTextFiled;

        /* internal */ /* var */_itemArr: Array<any>;
    }
